﻿
using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.step
{
    public class StepUpdateHandler : IRequestHandler<StepUpdateCommond, ResultsDTO>
    {


        private readonly IBateRepository<ProcessStep> _ProcessStep;

        public StepUpdateHandler(IBateRepository<ProcessStep> processStep)
        {
            _ProcessStep = processStep;
        }

        public async Task<ResultsDTO> Handle(StepUpdateCommond request, CancellationToken cancellationToken)
        {
            var list = new ResultsDTO() { Code = 0 };

            var str = "update processstep SET Orderid='"+request.Orderid+"',MaterialURl='"+request.MaterialURl+"',AuxiliaryEquipment='"+request.AuxiliaryEquipment+"',MaterialF='"+request.MaterialF+"',StepDescription='"+request.StepDescription+"',MEss='"+request.MEss+"' WHERE Processtepid="+request.Processtepid+"";

            var getdate = new ProcessStep();

            DapperHelper dapperHelper = new DapperHelper();
            var Success = _ProcessStep.Add(str, getdate, dapperHelper.MangoMesWrite);

            if(Success!=null)
            {
                list.Code = 1;

                list.Message = "工序步骤修改";
            }

            return list;

        }

    }



}
